using System;
using CSW.Framework.Common.Binding.Interfaces;
using CSW.Framework.Common.Binding.ValueTypes;

namespace CSW.Framework.Common.Binding.Events
{
    /// <summary>
    /// Provides data for the <see cref="INotifyInvalidData.InvalidData"/> event.
    /// </summary>
    public sealed class InvalidDataEventArgs : EventArgs
    {
        private readonly String m_Property;
        private readonly String m_Message;
        private readonly ErrorType m_ErrorType;

        /// <summary>
        /// Initializes a new instance of the <see cref="InvalidDataEventArgs"/> class.
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="message">The error or warning message.</param>
        public InvalidDataEventArgs(String propertyName, String message)
            : this(propertyName, message, ErrorType.Warning)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="InvalidDataEventArgs"/> class.
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="errorType">Type of the error.</param>
        public InvalidDataEventArgs(String propertyName, ErrorType errorType)
            : this(propertyName, String.Empty, errorType)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="InvalidDataEventArgs"/> class.
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="message">The error or warning message.</param>
        /// <param name="errorType">Type of the error.</param>
        public InvalidDataEventArgs(String propertyName, String message, ErrorType errorType)
        {
            m_Property = propertyName;
            m_Message = message;
            m_ErrorType = errorType;
        }

        /// <summary>
        /// Gets the property name.
        /// </summary>
        /// <value>The property name.</value>
        public String Property
        {
            get
            {
                return m_Property;
            }
        }

        /// <summary>
        /// Gets the error or warning message.
        /// </summary>
        /// <value>The error or warning message.</value>
        public String Message
        {
            get
            {
                return m_Message;
            }
        }

        /// <summary>
        /// Gets the type of the error.
        /// </summary>
        /// <value>The type of the error.</value>
        public ErrorType ErrorType
        {
            get
            {
                return m_ErrorType;
            }
        }
    }
}